package cn.itcast.topic;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * ErrorLogConsumer
 *
 * @author lee.siu.wah
 * @version 1.0
 * <p>File Created at 2020-11-24<p>
 */
@Component
public class ErrorLogConsumer {

    /**
     * 监听消息的方法
     */
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "${topic.error.queue}"), // 队列
            key = {"*.log.*"}, // 路由键
            exchange = @Exchange(name = "${mqlog.topic}", type = ExchangeTypes.TOPIC))) // 交换机
    public void handlerMesage(String msg){
        System.out.println("error--->接受到的消息是：" + msg);
    }
}
